Skip to content

fix(research): inherit main model's Bedrock region prefix in sub-agent#185

Open
taxfree-python wants to merge 1 commit intohuggingface:mainfrom
taxfree-python:fix/research-subagent-bedrock-region-prefix
Open

fix(research): inherit main model's Bedrock region prefix in sub-agent#185
taxfree-python wants to merge 1 commit intohuggingface:mainfrom
taxfree-python:fix/research-subagent-bedrock-region-prefix

Conversation

@taxfree-python
Copy link
Copy Markdown

Fixes #184.

Problem

The research sub-agent hard-codes bedrock/us.anthropic.claude-sonnet-4-6, which AWS Bedrock rejects with "The provided model identifier is invalid." whenever the caller's region/account cannot reach the us.* cross-region inference profile (e.g. ap-northeast-1). The main agent itself is unaffected because the user-chosen profile id is passed straight through to LiteLLM — only the sub-agent overrides it.

Fix

Inherit the inference-profile prefix from the main model. If the user is running bedrock/jp.anthropic.claude-opus-4-7, the sub-agent now picks bedrock/jp.anthropic.claude-sonnet-4-6; same for global., apac., etc. The sub-agent stays on the cheaper Sonnet model — only the prefix follows the main agent's choice, matching the project's existing convention of letting the user's explicit profile selection drive Bedrock routing.

if main_model.startswith("bedrock/") and "anthropic" in main_model:
    head = main_model.split("/", 1)[1]
    region_prefix = head.split(".", 1)[0]
    return f"bedrock/{region_prefix}.anthropic.claude-sonnet-4-6"

The existing us. test case is preserved (the new logic still produces us. for a us. main model), and a new test covers global. / apac. prefixes.

Verification

Direct LiteLLM call from ap-northeast-1 before/after, against the same model the function returns:

bedrock/us.anthropic.claude-sonnet-4-6  -> BedrockException "The provided model identifier is invalid."  (the reported bug)
bedrock/jp.anthropic.claude-sonnet-4-6  -> OK   (what the patched function emits for the user's main model)

Unit tests pass:

$ pytest tests/unit/test_cli_rendering.py
======================== 7 passed, 5 warnings in 6.51s =========================

Caveats

This makes the sub-agent work for every prefix under which claude-sonnet-4-6 is published on Bedrock (currently us., jp., global.). If a user is on an exotic prefix that has no sonnet-4-6 variant, the sub-agent will still fail on that environment — but that's also true of the main agent on that prefix today, and addressing it would expand the scope beyond this fix.

The sub-agent hard-coded `bedrock/us.anthropic.claude-sonnet-4-6`,
which AWS Bedrock rejects with "The provided model identifier is
invalid" whenever the user runs in a region that can't reach the
`us.*` cross-region inference profile (e.g. `ap-northeast-1`).

Inherit the prefix the user already chose for the main model so the
sub-agent picks `jp.`, `apac.`, `global.`, ... matching whatever the
main agent is successfully using.
@taxfree-python taxfree-python force-pushed the fix/research-subagent-bedrock-region-prefix branch from 2449ec9 to 5c46551 Compare April 29, 2026 13:15
@taxfree-python
Copy link
Copy Markdown
Author

Note on the failing review check: it appears to be the standard anthropics/claude-code-action@v1 permission issue affecting external-fork PRs (Actor does not have write permissions to the repository). I see the same failure on other recent fork-based PRs (e.g. #180, #181, #182), while internal-branch PRs pass. The change here is unrelated — happy to rebase or adjust if you'd like a fresh run after any workflow tweak.

@aryan5v
Copy link
Copy Markdown

aryan5v commented Apr 29, 2026

@taxfree-python the failed Claude check is expected for external fork PRs. It only runs automatically for contributors with write access to avoid potential abuse of the review workflow and repo tokens. Maintainers can still trigger it

@fglogan
Copy link
Copy Markdown

fglogan commented May 3, 2026

closed per maintainer request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Research sub-agent ignores the main model's Bedrock inference-profile prefix

3 participants